home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / HippoDraw / HippoDrawSrc1.1 / Hippo.subproj / GraphicView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-25  |  5.7 KB  |  217 lines

  1. #import <appkit/View.h>
  2.  
  3. typedef enum { Normal, Resizing } DrawStatusType;
  4.  
  5. extern DrawStatusType DrawStatus;
  6. extern NXAtom DrawPboardType;
  7. extern BOOL InMsgPrint;
  8.  
  9. @interface GraphicView : View
  10. {
  11.     id glist;                /* the list of Graphics */
  12.     id slist;                /* the list of selected Graphics */
  13.     id saveList;            /* for saving/restoring slist */
  14.     id cacheWindow;            /* the off-screen cache */
  15.     struct {
  16.     unsigned int groupInSlist:1;    /* whether a Group is in the slist */
  17.     unsigned int cacheing:1;    /* whether cacheing or drawing */
  18.     unsigned int dirty:1;        /* whether edited since last save */
  19.     unsigned int grid:8;        /* grid size */
  20.     unsigned int showGrid:1;    /* whether grid is visible */
  21.     unsigned int locked:1;        /* some graphics are locked */
  22.     unsigned int gridDisabled:1;    /* whether grid is enabled */
  23.     unsigned int freeOriginalPaste:1;/* whether originalPaste needs free */
  24.     } gvFlags;
  25.     short *gupCoords;            /* points in the grid user path */
  26.     int gupLength;            /* number of points in gupCoords */
  27.     char *gupOps;            /* movetos and linetos in the gup */
  28.     short *gupBBox;            /* bounding box of the gup */
  29.     float gridGray;            /* grayness of the grid */
  30.     int consecutivePastes;        /* number of consecutive pastes */
  31.     int lastPastedChangeCount;        /* the change count of last paste */
  32.     id editView;            /* flipped subview for editing */
  33.     id originalPaste;            /* the first pasted graphic */
  34.     BOOL serviceActsOnSelection;    /* whether a service has arguments */
  35. }
  36.  
  37. /* Class initialization */
  38.  
  39. + initialize;
  40.  
  41. /* Pasteboard lazy evaluation methods */
  42.  
  43. + convert:(NXTypedStream *)ts to:(const char *)type using:(SEL)writer toPasteboard:pb;
  44. + pasteboard:sender provideData:(const char *)type;
  45.  
  46. /* Creation methods */
  47.  
  48. - initFrame:(const NXRect *)frameRect;
  49.  
  50. /* Free method */
  51.  
  52. - free;
  53.  
  54. /* Private methods */
  55.  
  56. - selectionCache;
  57. - getBBox:(NXRect *)bbox of:list;
  58. - getBBox:(NXRect *)bbox of:list extended:(BOOL)extended;
  59. /*
  60.  * Returns a rectangle which encloses all the objects in the list.
  61.  */
  62. - recacheSelection;
  63. - getSelection;
  64. - saveSelection;
  65. - restoreSelection;
  66. - compositeSelection:(const NXRect *)sbounds from:(int)gstate;
  67. - (int)cacheSelection;
  68.  
  69. - cacheGraphic:graphic;
  70. - resetGUP;
  71. - (BOOL)move:(NXEvent *)event;
  72. - dragSelect:(NXEvent *)event;
  73.  
  74. /* Public methods */
  75.  
  76. - currentGraphic;
  77.  
  78. - dirty;
  79. - (BOOL)isDirty;
  80. - (BOOL)isEmpty;
  81. - (BOOL)hasEmptySelection;
  82.  
  83. - graphicsPerform:(SEL)aSelector andDraw:(BOOL)flag;
  84. - graphicsPerform:(SEL)aSelector with:(void *)argument andDraw:(BOOL)flag;
  85. - graphicsPerformSingle:(SEL)aSelector with:(void *)argument on:(id) g;
  86.  
  87. - cache:(const NXRect *)rect;
  88.  
  89. - removeGraphic:graphic;
  90. - insertGraphic:graphic;
  91. - insertGraphicNoSelect:graphic;
  92. - selectedGraphic;
  93.  
  94. - (int)gridSpacing;
  95. - (BOOL)gridIsVisible;
  96. - (BOOL)gridIsEnabled;
  97. - (float)gridGray;
  98. - setGridSpacing:(int)gridSpacing;
  99. - setGridEnabled:(BOOL)flag;
  100. - setGridVisible:(BOOL)flag;
  101. - setGridGray:(float)gray;
  102. - setGridSpacing:(int)gridSpacing
  103.     andGray:(float)gray;
  104. - grid:(NXPoint *)point;
  105.  
  106. - placeGraphic:graphic at:(const NXPoint *)location;
  107. - loadImageFromStream:(NXStream *)stream at:(const NXPoint *)location allowAlpha:(BOOL)alphaOk;
  108.  
  109. /* Writing alternate types of data */
  110.  
  111. - writePSToStream:(NXStream *)stream;
  112. - writeTIFFToStream:(NXStream *)stream;
  113.  
  114. /* Methods overridden from superclass */
  115.  
  116. - sizeTo:(NXCoord)width :(NXCoord)height;
  117. - mouseDown:(NXEvent *)event;
  118. - drawSelf:(const NXRect *)rects :(int)rectCount;
  119. - keyDown:(NXEvent *)event;
  120.  
  121. /* Copying the selection to a stream */
  122.  
  123. - copySelectionAsPS:(NXStream *)stream;
  124. - copySelectionAsTIFF:(NXStream *)stream;
  125. - copySelectionToStream:(NXStream *)stream;
  126.  
  127. /* Generic pasteboard methods */
  128.  
  129. - copyToPasteboard:pboard types:(NXAtom *)types;
  130. - copyToPasteboard:pboard;
  131. - pasteFromPasteboard:pboard;
  132.  
  133. /* Target/Action methods */
  134.  
  135. - setCurrentGraphic:sender;
  136. - delete:sender;
  137. - cut:sender;
  138. - copy:sender;
  139. - paste:sender;
  140. - selectAll:sender;
  141. - deselectAll:sender;
  142. - lock:sender;
  143. - unlock:sender;
  144. - bringToFront:sender;
  145. - sendToBack:sender;
  146. - group:sender;
  147. - ungroup:sender;
  148. - changeAspectRatio:sender;
  149. - alignToGrid:sender;
  150. - sizeToGrid:sender;
  151. - enableGrid:sender;
  152. - hideGrid:sender;
  153.  
  154. /* Target/Action messages sent from Controls to set various parameters */
  155.  
  156. - takeGridValueFrom:sender;
  157. - takeGridGrayFrom:sender;
  158. - takeGrayValueFrom:sender;
  159. - takeLineWidthFrom:sender;
  160. - takeLineJoinFrom:sender;
  161. - takeLineCapFrom:sender;
  162. - takeLineArrowFrom:sender;
  163. - takeFillValueFrom:sender;
  164. - takeFrameValueFrom:sender;
  165. - takeLineColorFrom:sender;
  166. - takeFillColorFrom:sender;
  167. - takeTextColorFrom:sender;
  168.  
  169. - changeFont:sender;
  170.  
  171. /* Accepting becoming the First Responder */
  172.  
  173. - (BOOL)acceptsFirstResponder;
  174.  
  175. /* Printing-related methods */
  176.  
  177. - beginPrologueBBox:(NXRect *)boundingBox creationDate:(char *)dateCreated
  178.     createdBy:(char *)anApplication fonts:(char *)fontNames
  179.     forWhom:(char *)user pages:(int )numPages title:(char *)aTitle;
  180. - beginSetup;
  181.  
  182. /* Archiving methods */
  183.  
  184. - awake;
  185. - write:(NXTypedStream *)stream;
  186. - read:(NXTypedStream *)stream;
  187.  
  188. /* Validates whether a menu command makes sense now */
  189.  
  190. - (BOOL)validateCommand:menuCell;
  191.  
  192. /* Useful scrolling methods */
  193.  
  194. - scrollGraphicToVisible:graphic;
  195. - scrollPointToVisible:(const NXPoint *)point;
  196.  
  197. @end
  198.  
  199. /*
  200.  * Since we can't be sure that we have an InspectorPanel, we use the
  201.  * objective-C respondsTo: mechanism to see if we can send the message
  202.  * initializeGraphic: to [NXApp inspectorPanel].  This dummy interface
  203.  * declaration declares those messages (so that even if they don't exists,
  204.  * we can at least use them to check with respondsTo:).  We don't want
  205.  * to import DrawApp.h or InspectorPanel.h since we might accidentally
  206.  * introduce a dependency on them which wouldn't be caught because we
  207.  * imported both of their interfaces.
  208.  */
  209.  
  210. @interface PossibleInspectorPanel : Object
  211.  
  212. - inspectorPanel;
  213. - initializeGraphic:graphic;
  214.  
  215. @end
  216.  
  217.